package com.xzx.spark.core.simulation

import java.io.ObjectInputStream
import java.net.ServerSocket

/**
 *
 * 接收到Driver发送的逻辑进行计算
 *
 * @author xinzhixuan
 * @version 1.0
 * @date 2021-12-25 1:59 PM
 */
object Executor {
  def main(args: Array[String]): Unit = {
    println("接收到Driver发送的逻辑进行计算")
    val serverSocket = new ServerSocket(9999)
    val socket = serverSocket.accept()
    val objectInputStream = new ObjectInputStream(socket.getInputStream)
    val task = objectInputStream.readObject().asInstanceOf[Task]
    val result = task.compute()
    println("executor计算的结果：" + result)
    serverSocket.close()
  }
}
